-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nwm client IndexError: invalid index to scalar variable. #180
Comments
From the stack trace, it appears that the metadata field, |
I was able to resolve this issue by removing the index in the line 274 python/nwm_client/src/hydrotools/nwm_client/gcp.py # Extract scale factor
scale_factor = ds['streamflow'].scale_factor[0]
# fixed with
scale_factor = ds['streamflow'].scale_factor I am assuming that the metadata layout of NWM channel route link files is pretty static over time as we've not seen this issue before. I assume this is a deserialization issue propagating from, if I had to guess, xarray. It might be best if we push a hot fix that guards and type checks the |
Found the issue. It is propagating
I verified that rolling the version back to |
Now as to how we should proceed. I know previously I said:
In this case, I think it makes sense to just type check proposed solutionstreamflow = ds['streamflow']
# h5netcdf <= 0.13.0 always deserializes numeric attributes to numpy arrays.
# even if there will only be one item in the array.
if isinstance(streamflow.scale_factor, np.ndarray):
scale_factor = streamflow.scale_factor[0]
# h5netcdf > 0.13.0 deserializes numeric attributes to numpy arrays if there is more than scalar in the attribute.
# otherwise, a scalar numpy value is returned
else:
scale_factor = streamflow.scale_factor |
If the source attribute was a single scalar all along and was only returned in a |
After talking with @jarq6c offline, we came to a solution (please correct me where necessary @jarq6c). Given that |
… introduced by h5netcdf==0.14.0
Resolve Nwm client IndexError: invalid index to scalar variable. (#180)
Justin Hunter reported an issue when trying to retrieve a short range forecast using the
nwm_client
'sgcp.NWMDataService
. I verified that I can reproduce the issue locally.Reproduce
The text was updated successfully, but these errors were encountered: